#引入yolov5执行函数
import threading
import time

from detect import start_to_identify

#引入拍照函数
from identify_id import identify_id

#引入TCP连接函数
from models.Iclient import *
from take_photos import snapShotCt_Once

if __name__ == '__main__':
    # while True:
        Image_location=snapShotCt_Once(0)
        # Image_location = './1.jpg'
        save_path,s=start_to_identify(Image_location)
        try:
            s=s.split(",")[0].split(" ")[2]
            # print(len(s))
            # print(s)
            # print(save_path)
            if s == 'person' or 'persons':
                # print("yes")
                id = identify_id(Image_location)
                # print(id)
                Iclient(id)
                print("发现违法行为，上传完成")
        except Exception as e:
            # print(e)
            print("未发现违法行为")
        finally:
            time.sleep(5)
